package com.xing.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xing.DTO.ConferenceUserDTO;
import com.xing.entity.ConferenceUserEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @version 1.0
 * @Author Xing
 * @Date 2024/2/19 1:14
 */
@Mapper
public interface ConferenceUserDao extends BaseMapper<ConferenceUserEntity> {
    @Select("SELECT COUNT(*)\n" +
            "FROM con_conference_user\n" +
            "WHERE conference_id = #{conferenceId}\n" +
            "  AND user_id = #{userId} and del_flag = '0';")
    public Integer getConference(@Param("conferenceId") Long conferenceId,
                                 @Param("userId") Long userId);

    @Select("SELECT * \n" +
            "FROM con_conference_user\n" +
            "WHERE conference_id = #{conferenceId}\n" +
            "  AND user_id = #{userId} and del_flag = '0';")
    public ConferenceUserEntity getConferenceEntity(@Param("conferenceId") Long conferenceId,
                                                    @Param("userId") Long userId);

    @Select("SELECT con_conference_user.*, username\n" +
            "FROM con_conference_user\n" +
            "         left join sys_user on sys_user.id = con_conference_user.user_id\n" +
            "WHERE conference_id = #{conCode}\n" +
            "  AND con_conference_user.del_flag = 0;\n")
    public List<ConferenceUserDTO> GetDto(@Param("conCode") String conCode);

}
